import {getList} from "@/services/lulu";
import {message} from "antd";
// @author:lf luLu列表20211104
const namespace = 'lulu';
const selectState = state => state[namespace];
const Model = {
  namespace,
  state: {
    topics: [],
    title: ''
  },
  effects: {
    * fetchTopics(_, {call, put, select}) {
      const {title} = yield select(selectState);
      const result = yield call(getList, {title});
      yield put({
        type: 'overrideStateProps',
        payload: {topics: result.data}
      });

    },
    * paginationTopics(_, {call, put, select}) {
      const {size, page} = yield select(selectState);
      const result = yield call(getList, {size, page});
      yield put({
        type: 'overrideStateProps',
        payload: {topics: result.data}
      })
    }
  },
  reducers: {
    overrideStateProps(state, {payload}) {
      return {
        ...state,
        ...payload
      }
    }
  }
};

export default Model;

